<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>开发平台</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
	<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.5.0/css/font-awesome.min.css">
	<link rel="stylesheet" href="/view/login/login.css">
	<!--<script src="/webjars/jquery/jquery.min.js"></script> -->
</head>
<body class="bg-white">
        <section id="content" class="m-t-lg wrapper-md animated fadeInUp">
            <div class="row m-n">
                <div class="col-md-4 col-md-offset-4 m-t-lg">
                    <section class="panel well">
                        <header class="panel-heading text-center bg-primary"><h4>登录<span class="label bg-info pull-right">v1.0.0</span></h4></header>
                        <form id="loginForm" action="/login" class="panel-body" method="post">
                            <div class="form-group">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"><i class="fa fa-user"></i></span>
                                    <input value="" class="form-control" placeholder="输入用户名" id="username" name="username" type="text">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="input-group m-b">
                                    <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                                    <input style="" class="form-control" placeholder="输入密码" id="password" name="password" type="password">
                                </div>
                            </div>
							<span class="errormsg"></span>
                            <!--
                              <div class="checkbox">
                                <label>
                                  <input type="checkbox"> Keep me logged in
                                </label>
                              </div>
                              
                              <a href="#" class="pull-right m-t-xs"><small>Forgot password?</small></a>
                            -->
                            <button type="button" class="btn btn-success btn-block btn-lg" id="submit" >登录</button>
                            <!--
                              <div class="line line-dashed"></div>
                              <a href="#" class="btn btn-facebook btn-block m-b-sm"><i class="icon-facebook pull-left"></i>Sign in with Facebook</a>
                              <a href="#" class="btn btn-twitter btn-block"><i class="icon-twitter pull-left"></i>Sign in with Twitter</a>
                              <div class="line line-dashed"></div>
                              <p class="text-muted text-center"><small>Do not have an account?</small></p>
                              <a href="signup.html" class="btn btn-white btn-block">Create an account</a>
                            -->
                        </form>
                    </section>
                </div>
            </div>
        </section>
        <!-- footer -->
        <!-- <footer id="footer"><div class="text-center padder clearfix"><p><small>Copyright © 2004-2017 北京安迪盟科技有限责任公司</small></p></div></footer> -->
<script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
<script src="/static/basic/plugins/easyui/jquery.easyui.min.js"></script>
<script src="/static/init.js?v=210628"></script>
<script src="https://cdn.staticfile.org/crypto-js/3.1.9/crypto-js.min.js"></script>
<script>
$(function(){
	$('#submit').bind('click', login);
	$('#btn1').bind('click', login);
});

function login(){
	var user = {};
	user.username = $("#username").val();
	user.password = $("#password").val();
	var check=true;
	if(user.username.length==0){
		$("#username").addClass("checkloin");
		setTimeout(function () {$("#username").removeClass("checkloin");}, 2000);
		check=false;
	}
	if(user.password.length==0){
		$("#password").addClass("checkloin");
		setTimeout(function () {$("#password").removeClass("checkloin");}, 2000);
		check=false;
	}
	if(check){
		access(user);
	}
}
function stringToHex(str){
	var val = "";
	for (var i = 0; i < str.length; i++) {
		val += str.charCodeAt(i).toString(16);
	}
	return val;
}
function access(userjson){
	/*var encrypwd;
	var salt="";
	var wordArray = CryptoJS.enc.Hex.parse(stringToHex(userjson.password)+salt);
	var hash = CryptoJS.MD5(wordArray);
	encrypwd=hash.toString();
	userjson.password=encrypwd;*/
	//userjson.phone_number=userjson.username;
	$.post("/login",JSON.stringify(userjson),function(result){
		if(result.success){
			/*if(loginkeeping){
				Cookie.set("ck_name",$("#userName").val(),{path: "/", expires: 7});
				Cookie.set("ck_loginkeeping","loginkeeping",{path: "/", expires: 7});
			}else{
				Cookie.remove("ck_name",{path: "/"});
				Cookie.remove("ck_loginkeeping",{path: "/"});
			}*/
			//window.location.href="/authenticated/main/main.html";
			window.location.replace("/view/sys/main/main.html");
		}else{
			$(".errormsg").html(result.message);
			setTimeout(function () {$(".errormsg").html("");}, 2000);
		}		
	});
}

</script>
</body>
</html>